USE [dbdata]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_BarCodeCards_identificator_sets]') AND parent_object_id = OBJECT_ID(N'[dbo].[BarCodeCards]'))
ALTER TABLE [dbo].[BarCodeCards] DROP CONSTRAINT [FK_BarCodeCards_identificator_sets]
GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_BarCodeCards_dt_in]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[BarCodeCards] DROP CONSTRAINT [DF_BarCodeCards_dt_in]
END

GO

USE [dbdata]
GO

/****** Object:  Table [dbo].[BarCodeCards]    Script Date: 03/18/2012 21:04:50 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[BarCodeCards]') AND type in (N'U'))
DROP TABLE [dbo].[BarCodeCards]
GO

USE [dbdata]
GO

/****** Object:  Table [dbo].[BarCodeCards]    Script Date: 03/18/2012 21:04:50 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[BarCodeCards](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[smsCode] [varchar](8) NOT NULL,
	[dt_in] [datetime] NOT NULL,
	[identificator_sets_id] [int] NULL,
	[dt_print] [datetime] NULL,
	[print_issue] [varchar](12) NULL,
	[print_page] [int] NULL,
	[dt_start] [datetime] NULL,
	[dt_off] [datetime] NULL,
 CONSTRAINT [PK_BarCodeCards] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[BarCodeCards]  WITH CHECK ADD  CONSTRAINT [FK_BarCodeCards_identificator_sets] FOREIGN KEY([identificator_sets_id])
REFERENCES [dbo].[identificator_sets] ([id])
GO

ALTER TABLE [dbo].[BarCodeCards] CHECK CONSTRAINT [FK_BarCodeCards_identificator_sets]
GO

ALTER TABLE [dbo].[BarCodeCards] ADD  CONSTRAINT [DF_BarCodeCards_dt_in]  DEFAULT (getdate()) FOR [dt_in]
GO

